package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
public class Ordered {
    private int userId;
    private Integer orderedId;
    private Date orderedTime;
    private Date orderTime;
    private String orderedMes;
    private User userByUserId;
    private Veg vegByVegId;

    @Id
    @Column(name = "user_id", nullable = false)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "ordered_id", nullable = true)
    public Integer getOrderedId() {
        return orderedId;
    }

    public void setOrderedId(Integer orderedId) {
        this.orderedId = orderedId;
    }

    @Basic
    @Column(name = "ordered_time", nullable = true)
    public Date getOrderedTime() {
        return orderedTime;
    }

    public void setOrderedTime(Date orderedTime) {
        this.orderedTime = orderedTime;
    }

    @Basic
    @Column(name = "order_time", nullable = true)
    public Date getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }

    @Basic
    @Column(name = "ordered_mes", nullable = true, length = 50)
    public String getOrderedMes() {
        return orderedMes;
    }

    public void setOrderedMes(String orderedMes) {
        this.orderedMes = orderedMes;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Ordered ordered = (Ordered) o;
        return userId == ordered.userId &&
                Objects.equals(orderedId, ordered.orderedId) &&
                Objects.equals(orderedTime, ordered.orderedTime) &&
                Objects.equals(orderTime, ordered.orderTime) &&
                Objects.equals(orderedMes, ordered.orderedMes);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, orderedId, orderedTime, orderTime, orderedMes);
    }

    @OneToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
    public User getUserByUserId() {
        return userByUserId;
    }

    public void setUserByUserId(User userByUserId) {
        this.userByUserId = userByUserId;
    }

    @ManyToOne
    @JoinColumn(name = "veg_id", referencedColumnName = "veg_id")
    public Veg getVegByVegId() {
        return vegByVegId;
    }

    public void setVegByVegId(Veg vegByVegId) {
        this.vegByVegId = vegByVegId;
    }
}
